<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta name="renderer" content="webkit">
<title>员工卡信息</title>
<link rel="stylesheet" type="text/css" href="../../css/cm-default.css"  />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/Gray2014/css/all.css" />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/ligerui-icons.css" />
<link rel="stylesheet" type="text/css" href="../../lib/bootstrap//css/bootstrap.css"/>
<link type="text/css" rel="stylesheet" href="../../css/public.css"  />
<link type="text/css" rel="stylesheet" href="../../css/pub.css"  />
<script src="../../lib/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../../lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="../../lib/autoInput/AutoInput.js" type="text/javascript"></script>
<script src="../../js/common.js" type="text/javascript"></script>

<script src="../../lib/bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script src="../../js/pub.js" type="text/javascript"></script>

<script type="text/javascript">
    var GridNameCode = [
        {"Key_Nvarchar":"userid","Value_Nvarchar":"卡号"},
        {"Key_Nvarchar":"ssn","Value_Nvarchar":"身份证号"},
    ] ;
    $(function() {
        InitAutoInput("gridName", GridNameCode, { key: "Key_Nvarchar", val: "Value_Nvarchar", format: "Value_Nvarchar" }, 'json');
    });
    var defGrid,paramS;
    paramS =new Object();
    $(function(){
        defGrid = $("#query_list").ligerGrid({
            columns:[
                {display:'卡号',name:'userid',width:60,minWidth:60,align:'left'},
                {display:'身份证号',name:'ssn',width:150,minWidth:60,align:'left'},
                {display:'性别',name:'sex',width:60,minWidth:60,align:'left'},
                {display:'姓名',name:'name',width:120,minWidth:60,align:'left'},
                {display:'公司',name:'company_id',width:130,minWidth:60,align:'left'},
                {display:'部门',name:'dept_id',width:130,minWidth:60,align:'left'},
                {display:'联系方式',name:'mobile_phone',width:120,minWidth:60},
            ],
            pageSize:10,
            usePager: true,
            dataAction:'server',
            url: '/employeeCard/queryCardInfoAll',
            contentType: "application/json; charset=utf-8",
            postData:paramS,
            width:'96%',
            height:'96%',
            checkbox:false,
            rownumbers:false,
            fixedCellHeight:false,
            colDraggable:true,
            enabledEdit:false,
            clickToEdit:false,
            isScroll:true,
            onDblClickRow:openMx,  //双击查询
            onSelectRow:function(rowdata, rowindex){$("#txtrowindex").val(rowindex);},
            param_org:'org_list'
        });
        $("#pageloading").hide();

    });

    var get_org_list=new function () {
        return getData('org_list');
    }
    function switcher_org(item) {
        return paramRender(item, defGrid.options.param_org, item.dept_id);
    }

    //查询方法
    function toQuery() {
		//设置查询条件参数
		paramS.userid = $("#useridQ").val();
		paramS.ssn = $("#ssnQ").val();
		//状态不赋值时，按默认条件查询。
		if($("#stateS").val())
		paramS.state=$("#stateS").val();
		
		paramS.data=JSON.stringify(paramS);
		// l-list 线性结构，默认；t-tree 树型结构
		paramS.rt='l';
		
		//重置页码
		defGrid.set({
			page : 1,
			newPage : 1,
			postData : paramS
		});
		// grid 重新加载数据
		defGrid.loadData();
    }

    
    //明细页面
    function openMx(userid){
        var row = defGrid.getSelectedRow();
        var UID=row.userid;
        parent.f_addTab('search_UserS'+UID,'单据明细信息','./html/card/employeeCardDetail.html?o=m&userid='.concat(UID));
    }
    /*
    	删除处理
    */
   function deleteRow() {
       var row = defGrid.getSelectedRow();
       if (!row) {
           $.ligerDialog.error('请先选择要删除的员工卡信息记录。','错误');
           return;
       }
       var userid = row.userid;
       $.ligerDialog.confirm('您确定要删除该项数据吗？', function(r) {
           if (!r){
        	  return;
           }
          toDel(userid);
          defGrid.deleteRow(userid);
       })
   }
 //查询方法
   function toQuery() {
       var key = $("#gridNameCode").val();
       var val = $("#gridName").val();
       key = key.split("Q")[0];
       //设置查询条件参数
       switch (key)
       {
           case "userid":
               paramS.userid = val;
               break;
           case "ssn":
               paramS.ssn = val;
               break;
           default:
               paramS.userid = "";
               paramS.ssn = "";
       }

       paramS.data=JSON.stringify(paramS);
       // l-list 线性结构，默认；t-tree 树型结构
       paramS.rt='l';
       //重置页码
       defGrid.set({
           page : 1,
           newPage : 1,
           postData : paramS
       });
       // grid 重新加载数据
       defGrid.loadData();
   }
   // 删除处理业务处理
   function toDel(userid) {
       ajaxSubmitGet("/employeeCard/deleteCardInfo/" + userid,function(data) {
           if (data) {
               if (parseInt(data['status']) > 0) {
                   toQuery();
                   $.ligerDialog.success('删除成功');
               } else {
                   $.ligerDialog.error('删除失败');
               }
           }
       });
   }
</script>
<style type="text/css">
    label{margin: 5px 20px 5px 15px;}
    .fields{height:35px;padding-top:5px;}
    .dict-info{width: 260px;padding: 10px;}
    .diff {margin:3px 0;}
    .lineD {width:99%;float:left;position:relative;overflow:hidden;margin:10px 0 2px 2px}
    .labelD {width:13%;position:relative;float:left;padding-top:3px;}
    .dplD {width:36%;position:relative;float:left;}
    .title{font-size:14px;font-weight:bold;background-position:left;padding-left:18px;}
    .l-dialog-content-nopadding{padding:0 !important;}
</style>
</head>
<body>
<div class="list_tab contextHeight">
    <div class="searchContent">
    	<div class="commenSearch">
            <div class="commenGotoSite">
                <button type="button" onclick="openMx()" class="form_Button btn btn-primary btn-xs">查看明细</button>
				<button type="button" onclick="deleteRow()" class="form_Button btn btn-primary btn-xs">员工卡删除</button>
            </div>
            <div class="commenSearchSite">
                <div class="form-inline" action="">
                    <div class="form-group contextWidth">
                        <div class="autoBox">
                            <span class="glyphicon glyphicon-search"></span>
                            <span class="commenSearchTitle"></span>
                            <input type="text" class="autoInput form-control input-sm" id="gridName" style="width:75%;" value="" autocomplete="off" />
                            <div class="autoList">
                            </div>
                            <input id="gridNameCode" name="gridNameCode" type="hidden" value="" />
                            <div style="display:inline-block;position:relative;">
                             	<span class="zkbutton" onclick="selectToggle(this);">
			                        	<span id="searchMark" class="glyphicon glyphicon-menu-down"></span>
			                        </span>
                            </div>
                            &nbsp;&nbsp;
                            <button type="button" onclick="toQuery();" class="btn btn-primary btn-sm">查询</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="searchForm" style="display:none;">
            <form id="form1" class="form-inline" action="">
               <div class="form-group">
                    <label for="useridQ">卡号:</label>
                    <input type="text" class="form-control input-sm" id="useridQ" placeholder="">
                </div>
                <div class="form-group">
                    <label for="ssnQ">身份证号:</label>
                    <input type="text" class="form-control input-sm" id="ssnQ" placeholder="">
                </div>
                &nbsp;&nbsp;
                <button type="button" onclick="toQuery();" class="btn btn-primary btn-sm">查询</button>
                &nbsp;&nbsp;
                <button type="button" onclick="toReset('#useridQ,#ssnQ,#dept_idQ');" class="btn btn-primary btn-sm">清空</button>
            </form>
        </div>
    </div>
    <div class="listTable">
        <div class="split_line"></div>
        <div id="query_list" style="padding: 0;margin:0 auto;"></div>
    </div>
</div>
<div id="pageloading"></div>
</body>
</html>